package com.woniuxy.school.dietary.food.controller;


import com.woniuxy.commons.core.model.Result;
import com.woniuxy.school.dietary.food.model.dto.FoodDto;
import com.woniuxy.school.dietary.food.model.from.FindFoodFrom;
import com.woniuxy.school.dietary.food.model.from.UpdateFoodFrom;
import com.woniuxy.school.dietary.food.service.FoodInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 吴彦祖
 * @since 2025年05月14日
 */
@RestController
@RequestMapping("/foodInfo")
@Api(tags = "菜品信息接口")
public class FoodInfoController {
    @Resource
    private FoodInfoService foodInfoService;
    /**
     * 查询菜品信息
     */
    @GetMapping("/findFood")
    @ApiOperation(value = "查询菜品信息")
    public Result<FoodDto> findFood(@SpringQueryMap FindFoodFrom from){
        FoodDto dto=foodInfoService.findFood(from);
        return Result.getResult(FoodDto.class).setCode(200).setMessage("查询菜品成功").setData(dto);
    }
    @PostMapping("/updateFood")
    @ApiOperation(value = "修改菜品信息")
    public Result updateFood(@RequestBody UpdateFoodFrom from){
        foodInfoService.updateFood(from);
        return Result.getResult().setCode(200).setMessage("修改菜品成功");
    }
}

